package com.itheima.aspectj.xml;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @author CC小天才
 * @website www.flyskill.cn
 * @date 2021/9/22 23:32
 **/

public class MyAspect {
    public void myBefore(JoinPoint joinPoint){
        System.out.println("前置通知：模拟执行权限检查....");
        System.out.println("目标类是："+joinPoint.getTarget());
        System.out.println(",被植入争强处理目标方法为："+joinPoint.getSignature().getName());
    }

    public void  myAfterReturning(JoinPoint joinPoint){
        System.out.print("后置通知：模拟记录.....,");
        System.out.println("被植入增强处理的目标为"+joinPoint.getSignature().getName());

    }

    public  Object myAround(ProceedingJoinPoint proceedingJoinPoint)throws  Throwable{
        System.out.println("环绕开始：执行目标方法之前，模拟开启事务...");
        Object object=proceedingJoinPoint.proceed();
        System.out.println("环绕结束：执行目标方法之后，模拟关闭事务...");
        return  object;
    }

    public void  myAfterThrowing(JoinPoint joinPoint,Throwable e){
        System.out.println("异常通知："+"出错了"+e.getMessage());
    }
    public void myAfter(){
        System.out.println("最终通知：模拟方法结束后的释放资源....");
    }

}
